//
//  DownloadingImageRowView.swift
//  FileManager-NSCache-HttpDownload
//
//  Created by DaleGuo on 2023/9/19.
//

import SwiftUI

// 一个单元的数据
struct DownloadingImageRowView: View {
    let model: PhotoModel

    var body: some View {
        HStack {
            //这里之所以不传PhotoModel，是为了让ImageView更通用，能处理各种各样的图片
            ImageView(url: model.url, key: "\(model.id)") // 用到了”一张图片“的view
                .frame(width: 75, height: 75)
            VStack {
                Text(model.title)
                    .font(.headline)
                Text(model.url)
                    .foregroundColor(.gray)
                    .italic()
            }
            .frame(maxWidth: .infinity, alignment: .leading)
        }
    }
}

struct DownloadingImageRowView_Previews: PreviewProvider {
    static var previews: some View {
        DownloadingImageRowView(model: PhotoModel(albumId: 1, id: 1, title: "Test", url: "https://via.placeholder.com/600/92c952", thumbnailUrl: "asffaaaw"))
            .padding()
            .previewLayout(.sizeThatFits)
    }
}
